Skip to content
This repository has been archived by the owner. It is now read-only.

Hackathon changes: rebuild support, code cleanup, simpler tests, install process. #3

Merged
merged 20 commits into from Sep 28, 2015
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b06a547
integration(npm): streamline installation process
Jul 13, 2015
de2a873
fix(npm): work with non-existing node_modules dir
Jul 13, 2015
f1dfec6
fix(npm): makefile doesn't relink anymore
Jul 13, 2015
6e8ac0b
docs(README): describe install process
Jul 13, 2015
59f9a26
binding.gyp: adds Mac OSX compatibility
conradkleinespel Jul 22, 2015
ecb0407
Merge pull request #1 from conradkleinespel/mzap/streamlining-patch
Jul 23, 2015
c1440f6
avoids rebuilding libraries if already present
conradkleinespel Jul 23, 2015
33b36bc
Merge pull request #1 from conradkleinespel/install-1
conradkleinespel Jul 23, 2015
c8bada5
fixes compilation errors
conradkleinespel Jul 9, 2015
d367e18
adds header include protection;
conradkleinespel Jul 10, 2015
7d6a57e
adds comments
conradkleinespel Jul 10, 2015
50ccaec
simplifies testing
conradkleinespel Jul 13, 2015
a818ac6
Merge pull request #2 from conradkleinespel/rebase-master
conradkleinespel Jul 23, 2015
018b596
fix(Makefile): doesn't relink anymore with npm install
jagu-sayan Jul 23, 2015
8b48158
Merge pull request #4 from jagu-sayan/patch-1
conradkleinespel Jul 23, 2015
a7591bb
removes `npm install node-gyp` on every `npm install`
conradkleinespel Jul 24, 2015
dcaf4f7
Merge pull request #5 from conradkleinespel/mffix
conradkleinespel Jul 30, 2015
68e0d1d
reconstruct: adds support for reconstructing 1 missing fragment
conradkleinespel Jul 30, 2015
6ff84e0
reconstruct: adds support for reconstructing multiple fragments
conradkleinespel Jul 30, 2015
d25e685
Merge pull request #6 from conradkleinespel/rebuild
conradkleinespel Jul 31, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -7,6 +7,11 @@ pids
*.pid
*.seed

# Erasure coding libs
erasurecode
gf_complete
Jerasure

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

@@ -27,5 +32,5 @@ build/*
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

# temptest.js should not be in the repo
# temptest.js should not be in the repo
test/temptest.js
@@ -0,0 +1,54 @@
TARGET = build/Release/node-eclib.node
GF = gf_complete
JERASURE = Jerasure
LIBERAS = erasurecode

LIBDIR = /usr/local/lib
LIBS = $(addsuffix .so, $(GF) $(JERASURE) $(LIBERAS))
DEPS = $(addprefix $(LIBDIR)/lib, $(LIBS))

LIB_EXT := so
ifeq ($(shell uname -s), Darwin)
LIB_EXT := dylib
endif
LIB_GUARD := find /usr 2>/dev/null -name '*.$(LIB_EXT)' | grep

all: $(DEPS)

$(GF):
$(LIB_GUARD) libgf_complete.$(LIB_EXT) || git clone http://lab.jerasure.org/jerasure/gf-complete.git $@

$(GF)/Makefile: | $(GF)
$(LIB_GUARD) libgf_complete.$(LIB_EXT) || ( cd $(GF) && ./autogen.sh && ./configure )

$(LIBDIR)/libgf_complete.so: $(GF)/Makefile
$(LIB_GUARD) libgf_complete.$(LIB_EXT) || ( $(MAKE) -C $(GF) && sudo $(MAKE) -C $(GF) install )

$(JERASURE):
$(LIB_GUARD) libJerasure.$(LIB_EXT) || git clone http://lab.jerasure.org/jerasure/jerasure.git $@

$(JERASURE)/Makefile: | $(JERASURE)
$(LIB_GUARD) libJerasure.$(LIB_EXT) || ( cd $(JERASURE) && autoreconf --force --install -I m4 && ./configure )

$(LIBDIR)/libJerasure.so: $(JERASURE)/Makefile
$(LIB_GUARD) libJerasure.$(LIB_EXT) || ( $(MAKE) -C $(JERASURE) && sudo $(MAKE) -C $(JERASURE) install )

$(LIBERAS):
$(LIB_GUARD) liberasurecode.$(LIB_EXT) || git clone https://bitbucket.org/tsg-/liberasurecode.git $@

$(LIBERAS)/Makefile: | $(LIBERAS)
$(LIB_GUARD) liberasurecode.$(LIB_EXT) || ( cd $(LIBERAS) && ./autogen.sh && ./configure )

$(LIBDIR)/liberasurecode.so: $(LIBERAS)/Makefile
$(LIB_GUARD) liberasurecode.$(LIB_EXT) || ( $(MAKE) -C $(LIBERAS) && $(MAKE) -C $(LIBERAS) test \
&& sudo $(MAKE) -C $(LIBERAS) install )

clean:
$(RM) $(TARGET)

distclean: clean
$(RM) -r $(GF) $(JERASURE) $(LIBERAS)

re: distclean all

.PHONY: all clean distclean re
@@ -1,38 +1,51 @@
# Node-ECLib
===================
This is the node port of required library
This is the node port of required library
https://bitbucket.org/tsg-/liberasurecode

Here is the main libraray Web site,
Here is the main library Website,
http://jerasure.org

Here is the python warpper of liberasurecode library
Here is the python wrapper of liberasurecode library
https://bitbucket.org/kmgreen2/pyeclib

To understand how the liberasurecode methods works please go though this class,
To understand how the liberasurecode methods works, please go through this
class,
https://bitbucket.org/tsg-/liberasurecode/src/e46c434e36566f6f0820923a9a184e27d7b941e8/test/liberasurecode_test.c?at=master

------------

### Setup
=========
Please see the SETUP.md file for the setup details.
A simple command will take care of everything for you:
```sh
npm install -g node-gyp # you might need to be root for this command
npm install
```
The install process will need to install libraries and node-gyp, requiring
sudo usage.

Running the test is done via the usual:
```sh
npm test
```


### Prestudy
===========
If you develop addons earlier then you probably knew it if not then it would be really helpfull to read these,
https://github.com/iojs/nan
If you developed addons before, then you probably knew it. If not, it would
be really helpful to read this:
[nan-documentation](https://github.com/iojs/nan)


### Project structure
============
Here is the details
Here are the details

## Js Files
* eclib-enum.js #
* eclib-enum.js #
This file will contain all the enum values that was introduced in the c project to keep the simillarity among the projects.
* eclib-util.js #
* eclib-util.js #
This contain all the util method that was required by the node-eclib.js file
* node-eclib.js #
This file has some commented out code, please go through it. Initially it was a strait forward implementation. Currently the class has only the skeleton of the methods.
@@ -43,6 +56,6 @@ Here is the details
* asyncencode.cpp # This class holds all the encode methods. Partially implemented .(Previous plan was to use NAN's asyn task for encoding)
* asyncreconstruction.cpp # Just a dummy class for exposing fragment reconstruction
* libmain.cpp # This class will have all the method except those 5 methods. Partially implemented.
* Libutil.cpp # This class holds the util method for the all the classes. Just few methods are implemented here.
* libutil.cpp # This class holds the util method for the all the classes. Just few methods are implemented here.

---------
@@ -2,18 +2,28 @@
"targets": [
{
"target_name": "node-eclib",
"sources": [ "src/cpp/node-eclib.cpp"
,"src/cpp/libmain.cpp"
,"src/cpp/asyncencode.cpp"
,"src/cpp/asyncdecode.cpp"
,"src/cpp/asyncreconstruction.cpp"
,"src/cpp/libutil.cpp"
],
"sources": [
"src/cpp/node-eclib.cpp",
"src/cpp/libmain.cpp",
"src/cpp/asyncencode.cpp",
"src/cpp/asyncdecode.cpp",
"src/cpp/asyncreconstruction.cpp",
"src/cpp/libutil.cpp"
],
"include_dirs" : [
"<!(node -e \"require('nan')\")"
],
"libraries": [ "/usr/local/lib/liberasurecode.so" ]

"/usr/local/include/liberasurecode",
"<!(node -e \"require('nan')\")"
],
"conditions": [
['OS=="mac"', {
"libraries": [ "/usr/local/lib/liberasurecode.dylib" ]
}],
['OS=="linux"', {
"libraries": [
"$(shell out=`ldconfig -p | grep liberasurecode.so` && ldconfig -p | grep liberasurecode.so | rev | cut -d' ' -f1 | rev | sed 's/[^\/]\+$$//g' | sed -n '1p' | tr -d '\\n' && echo 'liberasurecode.so' || echo /usr/local/lib/liberasurecode.so)"
]
}]
]
}
]
}
@@ -1,32 +1,32 @@
// This class will be act as the enum container for the node-eclib module

module.exports = {
BackendId: {
"EC_BACKEND_NULL" : 0,
"EC_BACKEND_JERASURE_RS_VAND" : 1,
"EC_BACKEND_JERASURE_RS_CAUCHY" : 2,
"EC_BACKEND_FLAT_XOR_HD" : 3,
"EC_BACKEND_ISA_L_RS_VAND" : 4,
"EC_BACKEND_SHSS" : 5,
"EC_BACKENDS_MAX" : 99
},
BackendId: {
"EC_BACKEND_NULL": 0,
"EC_BACKEND_JERASURE_RS_VAND": 1,
"EC_BACKEND_JERASURE_RS_CAUCHY": 2,
"EC_BACKEND_FLAT_XOR_HD": 3,
"EC_BACKEND_ISA_L_RS_VAND": 4,
"EC_BACKEND_SHSS": 5,
"EC_BACKENDS_MAX": 99
},

ChecksumType: {
"CHKSUM_NONE" : 1,
"CHKSUM_CRC32" : 2,
"CHKSUM_MD5" : 3,
"CHKSUM_TYPES_MAX" : 99
},
ChecksumType: {
"CHKSUM_NONE": 1,
"CHKSUM_CRC32": 2,
"CHKSUM_MD5": 3,
"CHKSUM_TYPES_MAX": 99
},

ErrorCode : {
"EBACKENDNOTSUPP" : 200,
"EECMETHODNOTIMPL" : 201,
"EBACKENDINITERR" : 202,
"EBACKENDINUSE" : 203,
"EBACKENDNOTAVAIL" : 204,
"EBADCHKSUM" : 205,
"EINVALIDPARAMS" : 206,
"EBADHEADER" : 207,
"EINSUFFFRAGS" : 208
}
ErrorCode: {
"EBACKENDNOTSUPP": 200,
"EECMETHODNOTIMPL": 201,
"EBACKENDINITERR": 202,
"EBACKENDINUSE": 203,
"EBACKENDNOTAVAIL": 204,
"EBADCHKSUM": 205,
"EINVALIDPARAMS": 206,
"EBADHEADER": 207,
"EINSUFFFRAGS": 208
}
};
@@ -1,89 +1,91 @@
// All the util method will go here.
// Lets see how many methods do we need add here, might be in the future we goona need
// Lets see how many methods do we need add here, might be in the future we goona need
// another validator util

var enums = require("./eclib-enum.js");

function ECLibUtil(){
function ECLibUtil() {

this.isInt = function(n){
this.isInt = function(n) {
return typeof n === 'number' && n % 1 == 0;
}
}

ECLibUtil.prototype.getErrorMessage = function(errorcode){
ECLibUtil.prototype.getErrorMessage = function(errorcode) {

var errornumber = enums.ErrorCode;
var message = null;
var message = null;

switch(errorcode){
case -errornumber.EBACKENDNOTSUPP :
message = "Backend not supported";
switch (errorcode) {
case -errornumber.EBACKENDNOTSUPP:
message = "Backend not supported";
break;
case -errornumber.EECMETHODNOTIMPL :
message = "No method implemented";

case -errornumber.EECMETHODNOTIMPL:
message = "No method implemented";
break;
case -errornumber.EBACKENDINITERR :
message = "Backend instance is terminated";

case -errornumber.EBACKENDINITERR:
message = "Backend instance is terminated";
break;
case -errornumber.EBACKENDINUSE :
message = "Backend instance is in use";

case -errornumber.EBACKENDINUSE:
message = "Backend instance is in use";
break;
case -errornumber.EBACKENDNOTAVAIL :
message = "Backend instance not found";

case -errornumber.EBACKENDNOTAVAIL:
message = "Backend instance not found";
break;
case -errornumber.EBADCHKSUM :
message = "Fragment integrity check failed";

case -errornumber.EBADCHKSUM:
message = "Fragment integrity check failed";
break;
case -errornumber.EINVALIDPARAMS :
message = "Invalid arguments";

case -errornumber.EINVALIDPARAMS:
message = "Invalid arguments";
break;
case -errornumber.EBADHEADER :
message = "Fragment integrity check failed";

case -errornumber.EBADHEADER:
message = "Fragment integrity check failed";
break;
case -errornumber.EINSUFFFRAGS :
message = "Insufficient number of fragments";

case -errornumber.EINSUFFFRAGS:
message = "Insufficient number of fragments";
break;

default:
message = "Unknown error";
break;
}

return message;
};
};

ECLibUtil.prototype.validateInstanceCreateParams = function( ec_backend_id, k, m, w, hd, ct){
ECLibUtil.prototype.validateInstanceCreateParams = function(ec_backend_id, k, m,
w, hd, ct) {

var retvalue = true;
var argslength = arguments.length;

retvalue = (argslength == 6);

while ( retvalue && (argslength> 0) ){
retvalue = retvalue && this.isInt( arguments[argslength - 1]);
while (retvalue && (argslength > 0)) {
retvalue = retvalue && this.isInt(arguments[argslength - 1]);
argslength--;
}

return retvalue;
};

ECLibUtil.prototype.validateEncodeParams = function( ec_id, orig_data, deta_length,callback ){
ECLibUtil.prototype.validateEncodeParams = function(ec_id, orig_data,
deta_length, callback) {

var retvalue = true;
var argslength = arguments.length;

retvalue = (argslength == 4);
retvalue = retvalue && this.isInt( arguments[0]);
retvalue = retvalue && this.isInt( arguments[2]);
retvalue = retvalue && this.isInt(arguments[0]);
retvalue = retvalue && this.isInt(arguments[2]);
retvalue = retvalue && (orig_data !== undefined) && Buffer.isBuffer(orig_data);
// Will check whether the callback is a method or not
//retvalue = retvalue && Buffer.isBuffer(orig_data);
@@ -94,5 +96,4 @@ ECLibUtil.prototype.validateEncodeParams = function( ec_id, orig_data, deta_leng




module.exports = ECLibUtil;